//
//  UIImage+Category.h
//  lc-collect
//
//  Created by mac on 2021/3/3.
//

#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

@interface UIImage (Category)

/// 由颜色生成图片
+ (UIImage *)imageWithColor:(UIColor*)color;

/// 将图片剪裁至目标尺寸
+ (UIImage *)imageByScalingAndCroppingForSourceImage:(UIImage *)sourceImage targetSize:(CGSize)targetSize;

/// 图片旋转角度
- (UIImage *)imageRotatedByDegrees:(CGFloat)degrees;

/// 拉伸图片UIEdgeInsets
- (UIImage *)resizableImage:(UIEdgeInsets)insets;

/// 拉伸图片CGFloat
- (UIImage *)imageByResizeToScale:(CGFloat)scale;

/// 放大图片CGSize
- (UIImage *)imageByResizeWithMaxSize:(CGSize)size;

/// 小样图图片CGSize
- (UIImage *)imageWithThumbnailForSize:(CGSize)size;

/// 通过Rect剪裁图片
- (UIImage *)imageByCropToRect:(CGRect)rect;

/// 图片增加圆角
- (UIImage *)imageByRoundCornerRadius:(CGFloat)radius;

/// 图片增加圆角及边框
- (UIImage *)imageByRoundCornerRadius:(CGFloat)radius
                          borderWidth:(CGFloat)borderWidth
                          borderColor:(UIColor *)borderColor;

/// 图片向左90度
- (UIImage *)imageByRotateLeft90;

/// 图片向右90度
- (UIImage *)imageByRotateRight90;

/// 图片转180度
- (UIImage *)imageByRotate180;

/// 根据颜色返回一张图片
/// @param color 颜色
/// @param rect 大小
+ (UIImage *)createImageWithColor:(UIColor *)color rect:(CGRect)rect;

/// 毛玻璃
- (UIImage *)xk_blearImageWithBlurLevel:(CGFloat)blurLevel;

/// 加水印
- (UIImage *)xk_waterImageWithImage:(UIImage *)waterImage;

/// 无渲染图片
- (UIImage *)xk_OriginalRenderingImage;

/// 创建二维码
/// @param codeString 字符串,url时传@"http://xxx"即可
/// @param size 尺寸
+ (UIImage *)xk_createQRCodeWithString:(NSString *)codeString size:(CGFloat)size;
+ (UIImage *)xk_createQRCodeWithString:(NSString *)codeString waterImage:(UIImage *)waterImage size:(CGFloat)size;

/// 获取视频第一帧图片
/// @param path 视频地址
+ (UIImage *)xk_getVideoCover:(NSURL *)path;

@end

NS_ASSUME_NONNULL_END
